<include file="layout/header" />
<style type="text/css">
    .teamNum{
        height:34px;
        line-height:20px;
        color:#fff;
        font-size:16px;
    }
    .teamNum span{
        display: inline-block;
        padding:6px 10px;
        border-radius:5px;
        background:#f89000;
    }
    #dt_basic tbody tr td{
          vertical-align:middle;
          height: 44px;
    }
    #dt_basic tbody tr td:last-child{
        text-align: center;
    }
    #dt_basic tbody tr td button{
        display: inline-block;
        margin:0 10px;
        width: 85px;
    }
    #dt_basic tbody tr td b{
        display: inline-block;
        margin:0 10px;
        width: 70px;
    }
    .msg{
    	overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		width:355px;
		display: inline-block;
    }
    .Message{
    	position: relative;
    }
     .Message .showMore{
     	display: none;
     	position:absolute;
     	top:44px;
     	left: 0;
     	padding: 30px;
     	background:skyblue;
     	border: 1px solid #ddd;
     	z-index: 9999999;
     	color: #fff;
     	width: 420px;
     }
     .more{
     	display: inline-block;
	    position: relative;
	    top: -6px;
	    color: darkorange;
	    margin-left: 9px;
	    width: 15px;
     }
     .show{
     	display: block;
     }
     .rotate{
 		-moz-transform:rotate(180deg);
		
		-webkit-transform:rotate(180deg);
		
		-o-transform:rotate(180deg);  
		
		-ms-transform:rotate(180deg); 
		
		transform:rotate(180deg); 
 	}
 	.noread {
 		display: inline-block;
	    position: absolute;
	    top: 0;
	    left: 0;
 		color: #000;
 		
 	}
 	.noread span{
 		display: inline-block;
 		height:26px;
 		line-height: 26px;
 		padding: 0 6px;
 		margin: 0 3px;
 		background: orangered;
 		border-radius: 18px;
 		color: #fff;
 	}
 	tr:last-child{
 		border-bottom: 1px solid #ddd;
 	}
</style>
<div id="content">   
	<div class="modal fade myModal" data-id="" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	    <div class="modal-dialog">
	        <div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
	                    &times;
	                </button>
	                <h4 class="modal-title">
	                    	消息
	                </h4>
	            </div>
	            <div class="modal-body" >
	               <p>是否删除本条消息？</p>
	            </div>
	            <div class="modal-footer">
	            	<button type="button" class="btn btn-primary deleteMsg" data-dismiss="modal">确认
	                </button>
	                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭
	                </button>
	            </div>
	        </div><!-- /.modal-content -->
	    </div><!-- /.modal -->
	</div>
    <!-- widget grid -->
    <section id="widget-grid" class="">
    
        <!-- row -->
        <div class="row">
    
            <!-- NEW WIDGET START -->
            <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12 sortable-grid ui-sortable">
    
                <!-- Widget ID (each widget will need unique ID)-->
                <div class="jarviswidget jarviswidget-color-darken jarviswidget-sortable" id="wid-id-0" data-widget-editbutton="false" role="widget">
                    <header role="heading">
                    <div class="jarviswidget-ctrls" role="menu">   </div>
                    <span class="widget-icon"> <i class="fa fa-table"></i> </span>
                    <h2>消息列表</h2>
    
                    <span class="jarviswidget-loader"><i class="fa fa-refresh fa-spin"></i></span>
                    </header>
                        
                    <!-- widget div-->
                    <div role="content">
    
                        <!-- widget edit box -->
                        <div class="jarviswidget-editbox">
                            <!-- This area used as dropdown edit box -->
                        </div>
                        <!-- end widget edit box -->
                        <!-- widget content -->
                        <div class="widget-body no-padding">
                            <div class="widget-body-toolbar">
                                <div class="col-xs-12  col-lg-8 teamNum">
                                	<if condition="$num gt 0">
                                        <p class="noread">未读<span class="">{{$num}}</span>条</p>
                                    </if>
                                    <form action='' method="get" style="    margin-left: 94px; margin-top: -3px;">
                                        <label class="select col-xs-3">
                                            <select name="type" class=" form-control">
                                                <option value="-1" <if condition="$type eq -1">selected</if> >消息类型</option>
                                                <option value="0"  <if condition="$type eq 0">selected</if> >系统消息</option>
                                                <option value="1"  <if condition="$type eq 1">selected</if> >产品订单消息</option>
                                                <option value="2"   <if condition="$type eq 2">selected</if> >工程订单消息</option>
                                                <option value="3"  <if condition="$type eq 3">selected</if> >催单消息</option>
                                                <option value="4"  <if condition="$type eq 4">selected</if> >财务消息</option>
                                                <option value="5"  <if condition="$type eq 5">selected</if> >物流消息</option>
                                                <option value="6"   <if condition="$type eq 6">selected</if> >普通消息</option>
                                                <option value="7"  <if condition="$type eq 7">selected</if> >抢单消息</option>
                                                <option value="8"   <if condition="$type eq 8">selected</if> >抢单接单消息</option>
                                            </select>
                                        </label>
                                        <label class="select col-xs-2">
                                            <select name="receivetime" class=" form-control">
                                                <option value="-1" <if condition="$receivetime eq -1">selected</if> >消息状态</option>
                                                <option value="1"  <if condition="$receivetime eq 1">selected</if>  >已读消息</option>
                                                <option value="2"  <if condition="$receivetime eq 2">selected</if> >未读消息</option>
                                            </select>
                                        </label>
                                        <div class="input-group col-xs-1">
                                            <button class="btn btn-default btn-primary" type="submit">
                                                <i class="fa fa-search"></i> 搜索
                                            </button>
                                            <div class="input-group-btn">
                                                <a href="{{:url('manage/Index/msglist')}}"><button type="button" class="btn btn-default">
                                                   	 全部
                                                </button></a>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            <div id="dt_basic_wrapper" class="dataTables_wrapper form-inline" role="grid">
                                <div class="dt-wrapper" style="overflow: auto;">
                                    <table id="dt_basic" class="table table-striped table-bordered table-hover dataTable" aria-describedby="dt_basic_info">
                                        <thead>
                                            <tr role="row">
                                            	<th style="width: 90px;">
                                            		标记为已读
                                            	</th>
                                                <th>类型</th>
                                                <th style="width: 420px;">消息内容</th>
                                                <th>创建时间</th>
                                                <th style="width: 265px;">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody role="alert" aria-live="polite">
                                            <volist name='data' id='vo'>
                                                <tr class="odd" bid='{{$vo.id}}'>
                                                	<td>
                                                        <input type="checkbox"  <if condition="$vo.receivetime gt 0">checked</if> class="mark" name="" id="" value="" />
                                                	</td>
                                                    <td>
                                                        <if condition="$vo.type eq 0">系统消息
                                                            <elseif condition="$vo.type eq 1"/>产品订单消息
                                                            <elseif condition="$vo.type eq 2"/>工程订单消息
                                                            <elseif condition="$vo.type eq 3"/>催单消息
                                                            <elseif condition="$vo.type eq 4"/>财务消息
                                                            <elseif condition="$vo.type eq 5"/>物流消息
                                                            <elseif condition="$vo.type eq 6"/>普通消息
                                                            <elseif condition="$vo.type eq 7"/>抢单消息
                                                            <elseif condition="$vo.type eq 8"/>抢单接单消息
                                                        </if>

                                                    </td>
                                                    <td class="Message"> 
	                                            		<span class="msg">{{$vo.content}}</span>  
	                                            		<img class="more" src="__IMG__/doubelup.png" alt="" />
	                                            		<!--<img class="more">>></span>-->
	                                            		<p class="showMore">{{$vo.content}}</p> 
	                                            	</td>
                                                    <!--<td><textarea cols="100" disabled rows="2">{{$vo.content}}</textarea></td>-->
                                                    <td>{{$vo.sendtime|date="Y-m-d H:i:s",###}}</td>
                                                    <td>
                                                        <if condition="$vo.link">
                                                            <a href="{{$vo.link}}" class="btn btn-default btn-primary btn-xs en_info info_ck">详情</a>
                                                        </if>

                                                        <!--<if condition="$vo['receivetime'] eq 0">
                                                           <a class="btn btn-default btn-primary btn-xs   en_examine">标记为已读</a>&nbsp;
                                                        </if>-->
                                                        <a class="btn btn-default btn-danger btn-xs en_delete">删除</a>
                                                    </td>
                                                </tr>
                                            </volist>                                        
                                        </tbody>
                                    </table>
                                </div>
                                <div class="dt-row dt-bottom-row">
                                    <div class="row">
                                        <div class="col-sm-6"></div>
                                        <div class="col-sm-6 text-right">
                                            <div class="dataTables_paginate paging_bootstrap_full">
                                                <ul class="pagination">
                                                    {{$data->render()}}
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- end widget content -->
    
                    </div>
                    <!-- end widget div -->
                </div>
            </article>
            <!-- WIDGET END -->
        </div>
        <!-- end row -->
    </section>
    <!-- end widget grid -->
</div>
</div>
<script type="text/javascript">
	$(function(){
		$('.mark').click(function(){		
			if($(this).is(':checked')){
				var thiss = $(this);
        		var bid = thiss.parents().parent('tr').attr('bid');
        		console.log(bid);
				$.post('{{:url("manage/Index/mread")}}',{'id':bid}, function(res){
		            //window.location.reload();
		        });
			}
		})

		$(".Message").on("click",".more",function(){
			$(this).next().toggleClass("show");			
			$(this).toggleClass("rotate");
		});

	})
    //标记为已读
//  $(".en_examine").click(function(){
//      var thiss = $(this);
//      var bid = thiss.parents().parent('tr').attr('bid');
//      $.post('{{:url("manage/Index/mRead")}}',{'id':bid}, function(res){
//          window.location.reload();
//      });
//  });

    //删除
// 	function delete(){
//  	 $.post('{{:url("manage/Index/delMsg")}}',{'id':bid}, function(res){
//          thiss.parents('tr').remove();
//      });
//	}
    $(".en_delete").click(function(){
    	$(".myModal").modal("show"); 
        var me=this;
        var thiss = $(me);
        var bid = thiss.parents().parent('tr').attr('bid');
        $(".myModal").attr('data-id',bid);
        console.log(bid);
//      $(".deleteMsg").click(thiss,bid);		
		 
    });
    $(".deleteMsg").click(function(){
    	var bid=$(".myModal").attr('data-id');
    	console.log(bid);
    	 $.post('{{:url("manage/Index/delmsg")}}',{'id':bid}, function(res){
    	 	$("tr[bid='"+bid+"']").remove();
//          thiss.parents('tr').remove();
        });
    })
    
	$(".info_ck").click(function(){
		var bid = $(this).parents('tr').attr('bid');
		
		$.ajax({
			type:"post",
			url:"{{:url('manage/Index/mread')}}",
			data:{
				id:bid
			},
			success:function(data){
			console.log(bid)	
			}
		});
	})
</script>
<include file="layout/footer" />